package ch9;

/**
 * @author oldliu
 * @since 1.0
 */
public class GetMax2 {
    public static void main(String[] args) {
        int[] a = {9,4,39,-9,44,14,16,219,29};
        int max = a[0];
        for (int i = 0; i < a.length; i++) {
            if (max < a[i]) {
                max = a[i];
            }
        }
        int max2=a[0];
        for(int i=1;i<a.length;i++){
            //max >=max2>=a[i]
            if(a[i]>max2&&a[i]<max){
                max2=a[i];
            }else if(max==max2){
                max2=a[i];//!!!!!!!!
            }
        }
        if(max==max2){
            System.out.println("大家一样大，没有第二大");
        }else{
            System.out.println("第二大是"+max2);
        }
    }
}
